package com.yunfeng.common.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yunfeng.common.dao.UserRoleDAO;
import com.yunfeng.common.entity.impl.UserRole;
import com.yunfeng.common.service.UserRoleService;

/**
 * 
 */
@Service
@Transactional
public class UserRoleServiceImpl implements UserRoleService {

	private UserRoleDAO userRoleDAO;

	/**
	 * 构造函数
	 * 
	 * @param jpaRepository
	 */
	@Autowired
	public UserRoleServiceImpl(UserRoleDAO userRoleDAO) {
		this.userRoleDAO = userRoleDAO;
	}

	/**
	 * @param id
	 * @return
	 * @see com.yunfeng.common.service.UserRoleService#get(java.lang.Long)
	 */
	@Override
	public UserRole get(Long id) {
		return userRoleDAO.findOne(id);
	}

	@Override
	public void save(UserRole userRole) {
		userRoleDAO.save(userRole);
	}

	@Override
	public void delete(Long userRoleId) {
		userRoleDAO.delete(userRoleId);
	}

	/**
	 * @param userId
	 * @return
	 * @see com.yunfeng.common.service.UserRoleService#find(Long)
	 */
	public List<UserRole> find(Long userId) {
		return userRoleDAO.findByUserId(userId);
	}

}
